package cn.itsuorce.controller;

import cn.itsuorce.domain.Employee;
import cn.itsuorce.domain.Product;
import cn.itsuorce.query.ProductQuery;
import cn.itsuorce.service.IProductService;
import cn.itsuorce.utils.AjaxResult;
import cn.itsuorce.utils.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class ProductController {


    @Autowired
    private IProductService productService;
    /**
     * 查询所有，支持高级查询的条件
     *
     * @param productQuery
     * @return
     */
    @PatchMapping("/product")
    public AjaxResult Page(@RequestBody ProductQuery productQuery) {
        try {
            System.out.println(productQuery);
            Page<Product> page = productService.findPage(productQuery);
            System.out.println(page);
            return AjaxResult.me().setData(page);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMsg("操作失败！" + e.getMessage());
        }
    }
}
